package com.example.goods_service.dao;

import com.example.goods_service.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface GoodsDao_liujingxi {

    @Select("select * from t_commodity where id = ${id}")
    List<T_commodity> selectgoods(@Param("id")int id);

    @Select("SELECT picture_path_name FROM t_picture INNER JOIN t_commodity_picture ON t_picture.id =t_commodity_picture.picture_id where t_commodity_picture.commodity_id=${id}")
    List<T_picture> selectpicture(@Param("id")int id);

    @Select("SELECT attribute from t_commodity_allocation where id = ${id}")
    List<T_commodity_allocation> selectattribute(@Param("id")int id);

    @Select("select DISTINCT configuration_type from t_commodity a,t_selected_config b ,t_category_config c,t_config_details d where a.id = b.goods_id and b.config_id = c.id and b.config_details_id = d.id and a.id = ${id}")
    List<T_category_config> selectconfiguration_type(@Param("id")int id);

    @Select("select DISTINCT config_details from t_commodity a,t_selected_config b ,t_category_config c,t_config_details d where a.id = b.goods_id and b.config_id = c.id and b.config_details_id = d.id and a.id = ${id} and c.configuration_type='${color}'")
    List<T_config_details> selectcolor(@Param("color")String color,
                                       @Param("id") int id);

    @Select("select DISTINCT config_details from t_commodity a,t_selected_config b ,t_category_config c,t_config_details d where a.id = b.goods_id and b.config_id = c.id and b.config_details_id = d.id and a.id = ${id} and c.configuration_type='${er}'")
    List<T_config_details> selecter(@Param("er")String er,
                                    @Param("id") int id);

    @Select("select DISTINCT config_details from t_commodity a,t_selected_config b ,t_category_config c,t_config_details d where a.id = b.goods_id and b.config_id = c.id and b.config_details_id = d.id and a.id = ${id} and c.configuration_type='${san}'")
    List<T_config_details> selectsan(@Param("san")String san,
                                     @Param("id")int id);

    @Select("select DISTINCT config_details from t_commodity a,t_selected_config b ,t_category_config c,t_config_details d where a.id = b.goods_id and b.config_id = c.id and b.config_details_id = d.id and a.id = ${id} and c.configuration_type='${si}'")
    List<T_config_details> selectsi(@Param("si")String si,
                                    @Param("id")int id);

    @Select("select  price from t_commodity_allocation where commodity_id=${id} and attribute like '%${attribute}%'")
    List<T_commodity_allocation> selectprice(@Param("id")int id,
                                    @Param("attribute")String attribute);

    @Select("select stock from t_commodity_allocation where commodity_id=${id} and attribute like '%${attribute}%'")
    List<T_commodity_allocation> selectstock(@Param("id")int id,
                                             @Param("attribute")String attribute);
}
